//
//  JieGuoView.m
//  AILove
//
//  Created by 甘世清 on 2023/12/30.
//

#import "JieGuoView.h"

@implementation JieGuoView

- (void)SQ_UIViewForSelfView{
    self.backgroundColor = UIColor.clearColor;
    UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleRegular];
    UIVisualEffectView* visualView = [[UIVisualEffectView alloc]initWithEffect:effect];
     visualView.frame =CGRectMake(0, 0, SCREEN_WIDETH, SCREEN_HEIGHT);
      visualView.alpha = 0.92;
     [self addSubview:visualView];
    self.bgView = [[UIView alloc]init];
    self.bgView.backgroundColor = SQHexColor(@"#FFFFFF", 0.24);
    self.bgView.layer.cornerRadius = 12;
    self.bgView.layer.masksToBounds = YES;
    [self addSubview:self.bgView];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(295);
        make.height.mas_equalTo(176);
        make.centerX.centerY.equalTo(self);
    }];
    self.oneLabel= [[UILabel alloc]init];
    self.oneLabel.text = SQNSLocalString(@"解锁成功");
    self.oneLabel.textColor = SQColor(@"#FFFFFF");
    self.oneLabel.font = FONT_BOLD(18);
    [self.bgView addSubview:self.oneLabel];
    [self.oneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgView).offset(20);
        make.centerX.equalTo(self.bgView);
        make.height.mas_equalTo(18);
    }];
    self.towLabel= [[UILabel alloc]init];
    self.towLabel.text = SQNSLocalString(@"您已成功解锁指定照片，请点击查看");
    self.towLabel.textColor = SQColor(@"#FFFFFF");
    self.towLabel.font = FONT_MEDIUM(14);
    self.towLabel.textAlignment = NSTextAlignmentCenter;
    self.towLabel.numberOfLines = 0;
    [self.bgView addSubview:self.towLabel];
    [self.towLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgView).offset(62);
        make.centerX.equalTo(self.bgView);
        make.width.mas_equalTo(270);
    }];
    
    _btn = [[HeaderView alloc]init];
    _btn.font = FONT_MEDIUM(16);
    _btn.text = SQNSLocalString(@"好的");
    _btn.layer.cornerRadius = 4;
    _btn.headerImage.image = SQGetImage(@"按钮背景");
    [_btn.btn addTarget:self action:@selector(SQ_buttonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.bgView addSubview:_btn];
    [_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.bgView.mas_bottom).offset(-20);
        make.height.mas_equalTo(40);
        make.width.mas_equalTo(263);
        make.centerX.equalTo(self.bgView);
    }];
    
    _guanbi = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(15, 15) midmargin:0];
    _guanbi.image = SQGetImage(@"退出图标");
    [self addSubview:self.guanbi];
    [self.guanbi mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(self.bgView.mas_bottom);
            make.size.mas_equalTo(45);
    }];
    WS(weakSelf);
    [self.guanbi setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [weakSelf SQ_buttonClick];
    }];
    [self SQ_Header];
}
-(void)SQ_buttonClick{
    if (self.JGBlock) {
        self.JGBlock();
    }
}
- (void)setType:(NSInteger)type{
    _type = type;
    [self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(206);
    }];
}

- (void)SQ_Header{
    NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
    [HttpTool post:Url6 paramDic:dic successBlock:^(BaseModel * _Nonnull httpModel) {
        UserModel * mo = [UserModel share];
        UserModel* model = [UserModel mj_objectWithKeyValues:httpModel.data];
        model.token = mo.token;
        model.score = mo.score;
        [UserModel updateLocalUserModel:model];
    } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
        
    }];
}
@end
